package com.powerhua.privilege.dao;

import java.util.List;

import com.powerhua.privilege.domain.Privilege;


public interface PrivilegeDao {
	
	/**
	 * get permission by permission id
	 * @param pmId
	 * @return
	 */
	Privilege findPmById(String pmId);

	/**
	 * get permission by operation/resource value
	 * @param opValue
	 * @param resValue
	 * @return
	 */
	Privilege findPmByOpResValue(String opValue, String resValue);
	
	/**
	 * get permission by operation/resource id
	 * @param opId
	 * @param resId
	 * @return
	 */
	Privilege findPmByOpResId(String opId, String resId);

	
	// =====================
	// access check
	// =====================

	/**
	 * 
	 * @param userId
	 * @param pmId
	 * @return
	 */
	boolean accessCheckPmWithUser(String userId, String pmId);
	
	/**
	 * 
	 * @param userId
	 * @param pmId
	 * @return
	 */
	boolean accessCheckPmWithUserRole(String userId, String pmId);
	
	/**
	 * 
	 * @param userId
	 * @param pmId
	 * @return
	 */
	boolean accessCheckPmWithUserGroupRole(String userId, String pmId);
	
	/**
	 * 
	 * @param userId
	 * @param pmId
	 * @return
	 */
	boolean accessCheckPmWithUserPositionOrgGroupRole(String userId, String pmId);

	
	// =====================
	// get list
	// =====================
	
	/**
	 * get permission list by user id
	 * @param userId
	 * @return
	 */
	List getPmsByUser(String userId);
	
	/**
	 * get permission list by role id
	 * @param roleId
	 * @return
	 */
	List getPmsByRole(String roleId);
}
